<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('学生实验列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <p>实验名称：</p>
                            <input type="text" name="experimentName"/>
                        </li>

                        <li>
                            <p>课程名称：</p>
                            <input type="text" name="courseName"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('website:kaikecheck:edit')}]];
    var removeFlag = [[${@permission.hasPermi('website:kaikecheck:remove')}]];
    var prefix = ctx + "website/myexment";

    $(function() {
        var options = {
            url: prefix + "/list",
            modalName: "我的实验",
            columns: [{
                checkbox: true
            },
                {
                    field : 'id',
                    title : '序号',
                    visible: true,
                    formatter: function (value, row, index) {
                        return $.table.serialNumber(index);
                    }
                },
                {
                    field : 'experimentName',
                    title : '实验名称'
                },
                {
                    field : 'courseName',
                    title : '课程名称'
                },
                {
                    field : 'orderTime',
                    title : '课程时间'
                },
                {
                    field : 'section',
                    title : '节次',
                    formatter: function (value, row, index) {
                            return value="第"+value+"节";
                    }
                },
                {
                    field : 'userName',
                    title : '创建者'
                },
                /*{
                    field : 'userStates',
                    title : '状态',
                    formatter: function (value, row, index) {
                        if(value="0"){
                            return value="未开始";
                        }else if(value="1"){
                            return value="已开始";
                        }
                    }
                },*/
                {
                    field : 'experimentMessage',
                    title : '实验信息'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if(row.userStates="0"){
                            // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" onclick="details("+row.id+")"\')"><i class="fa fa-edit"></i>实验详情</a> ');
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="details(\'' + row.id + '\')"><i class="fa fa-edit"></i>开始实验</a> ');
                            // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="begin()"><i class="fa fa-edit"></i>开始实验</a> ');
                        }else if(row.userStates="1"){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)"><i class="fa fa-edit"></i>实验中</a> ');
                        }

                        // actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="authDataScope(\'' + row.roleId + '\')"><i class="fa fa-check-square-o"></i>数据权限</a> ');
                        // actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="authUser(\'' + row.roleId + '\')"><i class="fa fa-user"></i>分配用户</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
    function details(id){
        $.modal.openTab('实验详情',ctx+'website/myexment/details?id='+id)

    }
    // function fabu(id){
    //     /* var loginName = $.table.selectColumns("loginName");
    //      alert(loginName);
    //      return false;*/
    //     $.modal.confirm("确认要取消发布吗?", function() {
    //         $.ajax({
    //             type: 'post',
    //             dataType: 'json',
    //             url: prefix + "/cancelFabu",
    //             data: {
    //                 id:id,
    //             },
    //             cache: false,
    //             async: true,
    //             success: function (data) {
    //                 $.modal.alertSuccess("取消成功");
    //                 $.table.refresh();
    //             }
    //         });
    //     });
    // }

    // function kaike(id){
    //     /* var loginName = $.table.selectColumns("loginName");
    //      alert(loginName);
    //      return false;*/
    //     $.modal.confirm("确认要开课吗?", function() {
    //         $.ajax({
    //             type: 'post',
    //             dataType: 'json',
    //             url: prefix + "/kaike",
    //             data: {
    //                 id:id,
    //             },
    //             cache: false,
    //             async: true,
    //             success: function (data) {
    //                 $.modal.alertSuccess("开课成功");
    //                 $.table.refresh();
    //             }
    //         });
    //     });
    // }

    // function cnacleKaike(id){
    //     /* var loginName = $.table.selectColumns("loginName");
    //      alert(loginName);
    //      return false;*/
    //     $.modal.confirm("确认要取消开课吗?", function() {
    //         $.ajax({
    //             type: 'post',
    //             dataType: 'json',
    //             url: prefix + "/cancleKaike",
    //             data: {
    //                 id:id,
    //             },
    //             cache: false,
    //             async: true,
    //             success: function (data) {
    //                 $.modal.alertSuccess("取消成功");
    //                 $.table.refresh();
    //             }
    //         });
    //     });


</script>
</body>